package com.bll;

import java.util.ArrayList;

import com.dal.QCActivityDAO;
import com.model.QCActivity;

public class QCActivityBLO {
	public enum QCActivityEnum {
		Coding(1), Syntax(2);

		private final int id;

		QCActivityEnum(int i) {
			id = i;
		}

		QCActivityEnum parse(int i) throws Exception {
			for (QCActivityEnum e : QCActivityEnum.values()) {
				if (e.id == id) {
					return e;
				}
			}
			return null;
		}
	}

	private int qcActivityId;
	private String qcActivityName;

	public QCActivityBLO(int QCActivityId, String QCActivityName) {
		super();
		this.qcActivityId = QCActivityId;
		this.qcActivityName = QCActivityName;
	}

	// Methods

	public static ArrayList<QCActivityBLO> loadAllQCActivity() {
		ArrayList<QCActivity> list = new QCActivityDAO().select();
		return getQCActivityBLOListFromEntityList(list);
	}

	// Internal Methods
	private static ArrayList<QCActivityBLO> getQCActivityBLOListFromEntityList(
			ArrayList<QCActivity> list) {
		ArrayList<QCActivityBLO> QCActivityBLOlist = new ArrayList<QCActivityBLO>();
		for (QCActivity QCActivity : list) {
			QCActivityBLOlist.add(getQCActivityBLOFromEntity(QCActivity));
		}
		return QCActivityBLOlist;
	}

	private static QCActivityBLO getQCActivityBLOFromEntity(QCActivity entity) {
		return new QCActivityBLO(entity.getQCActivityID(), entity.getQCActivityName());
	}

	// Utility Methods
	public String getDisplayText() {
		return qcActivityName;
	}

	/**
	 * @return the QCActivityId
	 */
	public int getQCActivityId() {
		return qcActivityId;
	}

	/**
	 * @param QCActivityId
	 *            the QCActivityId to set
	 */
	public void setQCActivityId(int QCActivityId) {
		this.qcActivityId = QCActivityId;
	}

	/**
	 * @return the QCActivityName
	 */
	public String getQCActivityName() {
		return qcActivityName;
	}

	/**
	 * @param QCActivityName
	 *            the QCActivityName to set
	 */
	public void setQCActivityName(String QCActivityName) {
		this.qcActivityName = QCActivityName;
	}

}
